package request

import (
	"gitcode.com/G-YT/iHealth25/server/model/common/request"
	common "gitcode.com/G-YT/iHealth25/server/model/common/request"
	"gitcode.com/G-YT/iHealth25/server/model/system"
	"time"
)

// Register User register structure
type Register struct {
	Name         string `json:"name" example:"名称"`
	Username     string `json:"userName" example:"用户名"`
	Password     string `json:"passWord" example:"密码"`
	NickName     string `json:"nickName" example:"昵称"`
	HeaderImg    string `json:"headerImg" example:"头像链接"`
	AuthorityId  uint   `json:"authorityId" swaggertype:"string" example:"int 角色id"`
	Enable       int    `json:"enable" swaggertype:"string" example:"int 是否启用"`
	AuthorityIds []uint `json:"authorityIds" swaggertype:"string" example:"[]uint 角色id"`
	Phone        string `json:"phone" example:"电话号码"`
	Email        string `json:"email" example:"电子邮箱"`
	Province     string `json:"province" example:"省"`
	City         string `json:"city" example:"市"`
	Area         string `json:"area" example:"区/县"`
	Addr         string `json:"addr" example:"详细地址"`
}

// Login User login structure
type Login struct {
	Username  string `json:"username"`  // 用户名
	Password  string `json:"password"`  // 密码
	Captcha   string `json:"captcha"`   // 验证码
	CaptchaId string `json:"captchaId"` // 验证码ID
}

// ChangePasswordReq Modify password structure
type ChangePasswordReq struct {
	ID          uint   `json:"-"`           // 从 JWT 中提取 user id，避免越权
	Password    string `json:"password"`    // 密码
	NewPassword string `json:"newPassword"` // 新密码
}

type ResetPassword struct {
	ID       uint   `json:"ID" form:"ID"`
	Password string `json:"password" form:"password" gorm:"comment:用户登录密码"` // 用户登录密码
}

// SetUserAuth Modify user's auth structure
type SetUserAuth struct {
	AuthorityId uint `json:"authorityId"` // 角色ID
}

// SetUserAuthorities Modify user's auth structure
type SetUserAuthorities struct {
	ID           uint
	AuthorityIds []uint `json:"authorityIds"` // 角色ID
}

type ChangeUserInfo struct {
	ID           uint                  `gorm:"primarykey"`                                                                                                   // 主键ID
	Name         string                `json:"name" form:"name" gorm:"column:name;comment:名称;"`                                                              // 名称
	NickName     string                `json:"nickName" form:"nickName" gorm:"default:系统用户;comment:用户昵称"`                                                    // 用户昵称
	Phone        string                `json:"phone" form:"phone" gorm:"comment:用户手机号"`                                                                      // 用户手机号
	Password     *string               `json:"password"`                                                                                                     // 新密码
	AuthorityIds []uint                `json:"authorityIds" gorm:"-"`                                                                                        // 角色ID
	Email        string                `json:"email" form:"email" gorm:"comment:用户邮箱"`                                                                       // 用户邮箱
	HeaderImg    string                `json:"headerImg" form:"headerImg" gorm:"default:https://image.cushdylm.com/app/icon/iHealth/logo2.png;comment:用户头像"` // 用户头像
	Enable       int                   `json:"enable" form:"enable" gorm:"comment:冻结用户"`                                                                     //冻结用户
	Province     string                `json:"province" form:"province" gorm:"column:province;comment:省;"`                                                   // 省
	City         string                `json:"city" form:"city" gorm:"column:city;comment:市;"`                                                               // 市
	Area         string                `json:"area" form:"area" gorm:"column:area;comment:区/县;"`                                                             // 区/县
	Addr         string                `json:"addr" form:"addr" gorm:"column:addr;comment:详细地址;"`                                                            // 详细地址
	Authorities  []system.SysAuthority `json:"-" form:"openNum" gorm:"many2many:sys_user_authority;"`
	OpenNum      uint                  `json:"openNum" form:"openNum" gorm:"column:open_num;comment:服务站开通会员数量"`
}

type GetUserList struct {
	common.PageInfo
	Username string `json:"username" form:"username"`
	NickName string `json:"nickName" form:"nickName"`
	Phone    string `json:"phone" form:"phone"`
	Email    string `json:"email" form:"email"`
}

type BranchSearch struct {
	system.SysUser
	StartCreatedAt *time.Time `json:"startCreatedAt" form:"startCreatedAt"`
	EndCreatedAt   *time.Time `json:"endCreatedAt" form:"endCreatedAt"`
	request.PageInfo
}

type QueryByID struct {
	ID uint
}

type ServiceStation struct {
	UIDs string `json:"uids" form:"uids"`
	request.PageInfo
}
